<?php
session_start();
$username = $_SESSION['username'];
$password = $_SESSION['password'];
$image = $_REQUEST['image'];
//$image = substr($_POST['image'], strpos($_POST['image'], ",") + 1);

//var_dump(urlencode($image));
$url = "http://localhost:8080/moms-diary/services/picture/scrap";
//$username="rm.herwidodo@babytivities.com";
//$password="e8HSG6Mlj>";

//$postFields = array();

//files
//$postFields['image'] = base64_encode($image);

$auth = $username.":".$password;

$curl_handle = curl_init($url);

curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_USERPWD, $auth);
curl_setopt($curl_handle, CURLOPT_POST, true);
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, urlencode($image));

//execute the API Call
$returned_data = curl_exec($curl_handle);
$return =  curl_getinfo($curl_handle);
if($returned_data){
	header("Content-type: application/json");
	print $returned_data;
}

